package com.sdcx.agrobank.adapter;

import android.content.Context;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;

import com.sdcx.agrobank.R;
import com.sdcx.agrobank.bean.MingXIBean;
import com.sdcx.agrobank.holder.ActorAssessHolder;
import com.sdcx.agrobank.ui.activity.jiaoyiDetailActivity;

import java.util.ArrayList;
import java.util.List;


/*
 *@Author:田恒宇
 *@Date: 2020-01-09
 *@Time:20:07
 *@Description:展示
 */
public class MingxiAdapter extends RecyclerView.Adapter<ActorAssessHolder> {
    private Context context;
    ArrayList<MingXIBean> list;

    public MingxiAdapter(Context context, ArrayList<MingXIBean> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public ActorAssessHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_mingxi, parent, false);
        return new ActorAssessHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ActorAssessHolder holder, int position) {
        holder.title.setText(list.get(position).title);
        holder.time.setText(list.get(position).dates);
        holder.over.setText("余额:" + list.get(position).over);
        if (list.get(position).ZS == 1) {
            holder.price.setText("-" + list.get(position).price + ".00");
        } else if (list.get(position).ZS == 2) {
            holder.price.setText("+" + list.get(position).price + ".00");
        } else {
            holder.price.setText("-" + list.get(position).price + ".00");
        }

        holder.layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, jiaoyiDetailActivity.class);
                intent.putExtra("time", list.get(position).dates);
                //   intent.putExtra("orve",list.get(position).over);
                intent.putExtra("price", list.get(position).price);
                intent.putExtra("zs", list.get(position).ZS);
                intent.putExtra("position", position);
                ContextCompat.startActivity(context, intent, null);
            }
        });
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

}
